Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

clipboard access in vba

529 views
Skip to first unread message

Woody

unread,
Nov 1, 2001, 10:13:04 AM11/1/01
to
In VB, I can do this:

Clipboard.Clear
Clipboard.SetText "Hello world!"
MsgBox Clipboard.GetText()

If I do the same thing in VBA (for instance in a SUB), I get error:
"Run-time error '424':
Object required"

The error occurs on line "Clipboard.Clear". I assume this means that
there is no object that refers to the clipboard (as I guess happens
automatically in VB). Is there an easy way to do this in VBA
(specifically in Excel)? All I really want to do is to put the full
path name to the active workbook into the clipboard, so I can past it
into the VFP command window when I'm processing files by hand...

Thanks,
Woody

David McRitchie

unread,
Nov 1, 2001, 10:37:08 AM11/1/01
to
Chip Pearson has a page on Clipboard
http://www.cpearson.com/excel/clipboar.htm
see if last sentence in introductory paragraph helps.

HTH,
David McRitchie, Microsoft MVP - Excel [alternate/main sites below]
My Excel Macros: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.geocities.com/davemcritchie/excel/search.htm

"Woody" <sugar...@yahoo.com> wrote in message news:ed89da80.01110...@posting.google.com...

Vasant Nanavati

unread,
Nov 1, 2001, 10:48:58 AM11/1/01
to
Hi Woody:

The following will demonstrate the correct VBA syntax:

Sub ClipboardDemo(MyStr As String)
Dim DataIn As DataObject, DataOut As DataObject
Set DataIn = New DataObject
Set DataOut = New DataObject
With DataIn
.SetText MyStr
.PutInClipboard
End With
With DataOut
.GetFromClipboard
MsgBox .GetText
End With
End Sub
--
Regards,

Vasant.


"Woody" <sugar...@yahoo.com> wrote in message
news:ed89da80.01110...@posting.google.com...

0 new messages